<div class="layuimini-main">
	<div class="layui-form layuimini-form">
		<input type="hidden" name="roleId" />
		<div class="layui-form-item">
			<label class="layui-form-label"> 角色名称 </label>
			<div class="layui-input-block"> <input type="text" name="roleName" class="layui-input" lay-verify="required" />
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"> 角色描述 </label>
			<div class="layui-input-block"> <input type="text" name="roleDesc" class="layui-input" lay-verify="required" />
			</div>
		</div>
		<div class="layui-form-item">
			<label class="layui-form-label"> 备注 </label>
			<div class="layui-input-block"> <input type="text" name="remark" class="layui-input" lay-verify="required" />
			</div>
		</div>
		<div class="layui-form-item" pane="">
		    <label class="layui-form-label">状态</label>
		    <div class="layui-input-block">
		        <input type="checkbox" name="status" lay-skin="switch" lay-filter="switchTest" title="状态">
		    </div>
		</div>
		<div class="layui-form-item">
			<div class="layui-input-block">
				<button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
			</div>
		</div>
	</div>
</div>
<script src="lib/jquery-3.4.1/jquery-3.4.1.min.js" charset="utf-8"></script>
<script src="lib/jq-module/paigusu.min.js" charset="utf-8"></script>
<script>
    layui.use(['form'], function () {
        var form = layui.form,
            layer = layui.layer,
			table=layui.table,
            $ = layui.$;

        /**
         * 初始化表单，要加上，不然刷新部分组件可能会不加载
         */
        form.render();
        // 当前弹出层，防止ID被覆盖
		
		form.verify({
			
		});
		
        var parentIndex = layer.index;
        //监听提交
        form.on('submit(saveBtn)', function (data) {
			var formData=data.field;
			formData.status=='on' ? formData.status=1:formData.status=0;
			$.ajax({
				url : 'http://localhost:8006/sccRole',
				type: 'put',
				data: JSON.stringify(formData),
				contentType:'application/json;charset=UTF-8',
				success: function(result){
					console.log(result);
					//刷新页面
					table.reload('roleManagement');
					//关闭弹出层
					
				},error:function(result){
					console.log(result);
				}
			});
			layer.close(parentIndex);
            return false;
        });

    });
</script>
